<!doctype html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<title>烟草种子发芽检测系统</title>
		{% load static %}
		<link rel="shortcut icon" href="{% static 'img/seed.ico'%}" type="image/x-icon" />
		<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
		<link rel="stylesheet" href="{% static 'css/signin.css' %}">
		<script src="{% static 'js/jquery-3.6.0.min.js' %}"></script>
		<script src="{% static 'js/jquery.cookie.js' %}"></script>
		<script>
			$(function() {
				$('#myForm').submit(function() {
					if ($('#userid').val() != '' && $('#password').val() != '') {
						saveUserInfo();
						return true;
					} else {
						bootbox.alert({
							title: "错误",
							message: "用户名或密码不能输入为空！",
							size: 'small'
						});
						return false;
					}
				});

				if ($.cookie("saveme") == "true") {
					$("#saveme").prop("checked", true);
					$("#userid").val($.cookie("userid"));
					$("#password").val($.cookie("password"));
				}
			});
			//保存用户信息 
			function saveUserInfo() {
				if ($("#saveme").prop("checked") == true) {
					var userName = $("#userid").val();
					var passWord = $("#password").val();
					$.cookie("saveme", "true", {
						expires: 7
					}); // 存储一个带7天期限的 cookie 
					$.cookie("userid", userName, {
						expires: 7
					}); // 存储一个带7天期限的 cookie 
					$.cookie("password", passWord, {
						expires: 7
					}); // 存储一个带7天期限的 cookie 
				} else {
					$.cookie("saveme", "false", {
						expires: -1
					});
					$.cookie("userid", '', {
						expires: -1
					});
					$.cookie("password", '', {
						expires: -1
					});
				}
			}
		</script>
	</head>

	<body>
		<div class="container">
			<h3 class="form-signin-heading text-center text-primary">烟草种子发芽检测系统</h3>
			<form id="myForm" class="form-signin text-muted" action="/login/" method="post">
				<img src="{% static 'img/tobacoo.png' %}"
					class="form-control img-responsive rounded-circle mx-auto d-block justify-content-start"
					alt="..." />
				{% csrf_token %}
				<h4 class="form-signin-heading">请登录</h4>

				<input type="userid" id="userid" name="userid" class="form-control" placeholder="输入账号" required
					autofocus>

				<input type="password" id="password" name="password" class="form-control" placeholder="输入密码" required>
				<div class="checkbox">
					<label>
						<input type="checkbox" id="saveme" value="remember-me">记着密码
					</label>
				</div>
				<div class="mb-4" style="margin-bottom: 3rem;">
				<button class="btn btn-lg btn-primary btn-block" type="submit">登录</button>
				</div>
				<p class="mt-6 mb-3 " style="text-align: center;">仲恺农业工程学院 &copy;2022-2023</p>
			</form>

		</div> <!-- /container -->
<!-- 		<div class="fixed-bottom mb-4">
			<p class="text-muted" style="text-align: center;">
				仲恺农业工程学院 &copy;2022-2024</p>
		</div> -->

		<script src="{% static 'js/popper.min.js' %}"></script>		
		<script src="{% static 'js/bootstrap-input-spinner.js' %}"></script>
		<script src="{% static 'js/bootbox.min.js' %}"></script>
		
		<script src="{% static 'js/bootstrap-input-spinner.js' %}"></script>
		<script src="{% static 'js/bootstrap.bundle.min.js'%}"></script>
		<script src="{% static 'js/plugins/buffer.min.js'%}"></script>
		<script src="{% static 'js/plugins/filetype.min.js'%}"></script>
		<script src="{% static 'js/fileinput.js'%}"></script>
		<script src="{% static 'themes/fa5/theme.js'%}"></script>			
		<script src="{% static 'js/axios.min.js' %}"></script>
		
		<link rel="stylesheet" href="{% static 'css/datatables.min.css'%}" />
		<script src="{% static 'js/dataTables.min.js'%}"></script>
		<script src="{% static 'js/dataTables.min.js'%}"></script>
	</body>
</html>
